<template>
  <div class="app-container">
    <div>
      <el-row :gutter="10">
        <el-col :span="6" :xs="24" :lg="24">
          <div class="bgwhite plr20 ptb20 radius10 flex-col">
            <div class="justify-between w100p">
              <div class="clr3c4 bold ft26">編輯</div>
              <div class="clr9fa align-center pointer" @click="back()">
                <el-icon>
                  <Back />
                </el-icon>
                返回上一頁
              </div>
            </div>
            <div class="mt40">
              <el-form :label-position="labelPosition" label-width="auto" :model="formLabelAlign" style="max-width: 600px">
                <el-form-item label="ID:">
                  <el-input v-model="formLabelAlign.id" disabled style="width: 380px;" />
                </el-form-item>
                <el-form-item label="類型:">
                  <el-input v-model="formLabelAlign.name" placeholder="请输入" disabled />
                </el-form-item>
                <el-form-item label="獎勵金額:">
                  <el-input v-model="formLabelAlign.coin" placeholder="请输入" />
                </el-form-item>
                <el-form-item label="创建時間:">
                  <el-input v-model="formLabelAlign.created_at" disabled />
                </el-form-item>
                <el-form-item label="更新時間:">
                  <el-input v-model="formLabelAlign.updated_at" disabled />
                </el-form-item>
              </el-form>
              <div class="mt40 mb15 flex-cen ">
                <div class="align-center">
                  <el-button class="btn1" @click="reset()">重置</el-button>
                  <el-button class="btn2" @click="submit()">提交</el-button>
                </div>

              </div>
            </div>


          </div>

        </el-col>

      </el-row>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import type { FormProps } from 'element-plus'
import { signEdit } from '@/api/sign.js'

const labelPosition = ref<FormProps['labelPosition']>('right')
const route = useRoute()
onMounted(() => {
  console.log('签到数据', route.query)
  formLabelAlign.id = route.query.id
  formLabelAlign.coin = route.query.coin
  formLabelAlign.created_at = route.query.created_at
  formLabelAlign.updated_at = route.query.updated_at
  formLabelAlign.name = route.query.name
})
const formLabelAlign = reactive({
  id: 0,
  name: '',
  coin: '',
  created_at: '',
  updated_at: ''
})
const router = useRouter()
const back = () => {
  router.back()
}
const reset = () => {
  formLabelAlign.coin = ''
}
const submit = () => {
  signEdit({
    id: formLabelAlign.id,
    name: formLabelAlign.name,
    coin: formLabelAlign.coin
  }).then((res) => {
    console.log('提交', res)
    back()
  })

}
</script>
<style scoped >
:deep(.el-upload--picture-card) {
  background-color: transparent;
  border: none;
}

:deep(.el-input) {
  box-shadow: none;
}
</style>